	//라운드예약목록
	function clsScoreRecord_List(){
		this.listData = null;
		this._HTMLDom = null;		
		this.idx = 0;
		this._init();	
	}
	
	clsScoreRecord_List.prototype = {
		_init: function(){
			var $layer = $("section#my_score_record>section>form dl dt:eq(0)");
			var $info = $("section#my_score_record>section>form dl dd:eq(0) ul");
			this._HTMLDom = {
				"$layer": $layer	
				, "$info": $info
			}
			$layer.find("select").empty();
			$layer.find("select").selectmenu("refresh");
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"].find("select");
		
			for(var i=0;i<this.listData.length;++i){
				var courseInfo = "직접입력";
		
				//예약정보
				if(this.listData[i]["예약코드"]){
					var hole = this.listData[i]["홀1"] + this.listData[i]["홀2"];
					courseInfo = this.listData[i]["코스코드1"] +" / "+ hole +"H / "+ _util.fDateYmd(this.listData[i]["라운드정보"]["일자"]) +"("+ this.listData[i]["라운드정보"]["요일"] +") "+ _util.fTime(this.listData[i]["라운드정보"]["시간"]);					
				}
				
				$layer.append("<option value='#'>"+ courseInfo + "</option>");
			}
			
			this.setIdx(this.idx);
		}
		, setIdx: function(n){
			var $layer = this._HTMLDom["$layer"];
			var $info = this._HTMLDom["$info"];
			
			this.idx = n;
			$layer.find("select option").eq(n).prop("selected",true);
			$layer.find("select").selectmenu("refresh");
			
			if(this.idx == 0){
				$info.hide().eq(0).show();
			}else {
				$info.hide().eq(1).show();
				
				$info.eq(1).find("p:eq(0)").html(_util.fDateYmd(this.listData[n]["라운드정보"]["일자"]) +"("+ this.listData[n]["라운드정보"]["요일"] + ")");
				$info.eq(1).find("p:eq(1)").html(this.listData[n]["골프장코드"] + "&nbsp;" + this.listData[n]["코스코드1"]);
				$info.eq(1).find("p:eq(2)").html((this.listData[n]["홀1"] + this.listData[n]["홀2"]) + "&nbsp;H");
			}
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];			
			return $layer.find("select option").index($layer.find("select option:selected"));
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];	
		}
	}
	
	
	//라운드일자
	function clsScoreRecord_Date(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_Date.prototype = {
		_init: function(){
			var $layer = $("section#my_score_record>section>form dl dd:eq(0) ul:eq(0) li:eq(0)");
			this._HTMLDom = {
				"$layer": $layer					
			}
			
			var t = new Date();
			
			var y = $layer.find("select:eq(0)");
			var m = $layer.find("select:eq(1)");
			var d = $layer.find("select:eq(2)");
			
			$layer.find("select").empty();
			$layer.find("select").selectmenu("refresh");
			
			for(var i=1;i<=31; ++i){
				
				if(i<=5) y.append("<option>" + (t.getFullYear()+i) + "</option>");
				if(i<=12) m.append("<option>" + ("00"+i).substrEx(-2) + "</option>");
				d.append("<option>" + ("00"+i).substrEx(-2) + "</option>");
			}
			
			$layer.find("select").selectmenu("refresh");
		}
		, setValue: function(){
				
		}
		, getValue: function(){
			
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//코스정보
	function clsScoreRecord_Course(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_Course.prototype = {
		_init: function(){
			var $layer = $("section#my_score_record>section>form dl dd:eq(0) ul:eq(0) li:eq(1)");
			this._HTMLDom = {
				"$layer": $layer	
			}			
		}
		, setList: function(thisData){
			this.listData = thisData	
		}
		, setValue: function(v){
			this._HTMLDom["$layer"].find("input").val(v);
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].find("input").val();
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//홀정보
	function clsScoreRecord_Hole(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_Hole.prototype = {
		_init: function(){
			var $layer = $("section#my_score_record>section>form dl dd:eq(0) ul:eq(0) li:eq(2)");
			this._HTMLDom = {
				"$layer": $layer	
			}			
			this.setValue("18");
		}
		, setList: function(thisData){
			this.listData = thisData	
		}
		, setValue: function(v){
			this._HTMLDom["$layer"].find("input").val(v);
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].find("input").val();
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//사진첨부
	function clsScoreRecord_File(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_File.prototype = {
		_init: function(){
			var $layer = $();
			this._HTMLDom = {
				"$layer": $layer	
			}
		}
		, setList: function(thisData){
			this.listData = thisData	
		}
		, display: function(){
			
		}
		, setIdx: function(n){
			
		}
		, getValue: function(){
			
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//내용
	function clsScoreRecord_Text(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_Text.prototype = {
		_init: function(){
			var $layer = $("section#my_score_record>section>form dl dd:eq(1) textarea");
			this._HTMLDom = {
				"$layer": $layer	
			}
		}
		, setList: function(thisData){
			this.listData = thisData	
		}
		, setValue: function(v){
			this._HTMLDom["$layer"].val(v);
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].val();
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//스코어카드
	function clsScoreRecord_Card(){
			this._HTMLDom = null;
			this.listData = null;
			this.errMsg = null;
			this._ERRMSG = {
				"_NODATA" : "내용을 입력하여 주십시요."
			}
			this._init();
	}
	
	clsScoreRecord_Card.prototype = {
		_init: function(){
			var $layer = $();
			this._HTMLDom = {
				"$layer": $layer	
			}
		}
		, setList: function(thisData){
			this.listData = thisData	
		}
		, display: function(){
			
		}
		, setIdx: function(n){
			
		}
		, getValue: function(){
			
		}
		, isValid: function(){
			
		}
		, getError: function(){
			return this.errMsg;	
		}
	}
	
	//데이터연동		
	function clsComm_MyScoreRecord(){
		this.scoreSchedule = null;						
		this._init();
	}	
	clsComm_MyScoreRecord.prototype = {
		_init: function(){
			
		}
//------------------------ 라운드스케줄정보------------------------//					
		, getScoreScheduleList: function(){
			var thisClass = this;			
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
			objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getUserReservList");

        	cm.requestGet(objJson.getJsonString(), function(ret){
        	
				thisClass.scoreSchedule = [{
					"예약코드": null
					, "코스코드1": null
					, "코스코드2": null
					, "골프장코드": "직접입력"
					, "골프장코스": null
					, "홀1": null
					, "홀2": null
					, "라운드정보": {
						 "년": null
						 ,"월": null
						 ,"일": null
						 , "요일": null
						 , "시간": null
						 , "일자": null
					}
				}];
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var reserveTime = _util.nvl(obj["reservTime"]);
						
						thisClass.scoreSchedule.push({
							"예약코드": _util.nvl(obj["reservSeq"])
							, "코스코드1": _util.nvl(obj["courseInfoId1"])
							, "코스코드2": _util.nvl(obj["courseInfoId2"])
							, "골프장코드": _util.nvl(obj["golfclubId"])
							, "골프장코스": _util.nvl(obj["golfclubName"]) + "-" + _util.nvl(obj["courseInfoName"])
							, "홀1": _util.nvl(obj["holeCnt1"], 0)
							, "홀2": _util.nvl(obj["holeCnt2"], 0)
							, "라운드정보": {
								 "년": _util.nvl(obj["reservDate"]).substr(0, 4)
								 ,"월": _util.nvl(obj["reservDate"]).substr(4, 2)
								 ,"일": _util.nvl(obj["reservDate"]).substr(6, 2)
								 , "요일": "금"								 
								 , "일자": _util.nvl(obj["reservDate"]).substr(0, 8)
								 , "시간": _util.nvl(obj["reservDate"]).substr(8, 4)
							}							
						});
					}
				}
				
				thisClass.scoreSchedule.push({
					"예약코드": "D772"
					, "골프장코드": "골프장"
					, "코스코드1": "코스1"
					, "코스코드2": "코스2"
					, "코스코드3": "코스3"
					, "홀1":	9
					, "홀2":	9
					, "라운드구분": 1
					, "라운드정보": {
						"년": "2012"
						, "월": "07"
						, "일": "20"
						, "요일": "금"
						, "일자": "20120720"
						, "시간": "1930"						
					}
				});
				
				$(thisClass).trigger("evtFinishScheduleList");				
			}, function($err) {
				alert($err);
			});					
		}
		, getScoreScheduleListData: function(){
			return this.scoreSchedule;	
		}
//------------------------ 라운드스케줄정보------------------------//
//------------------------ 스코어등록------------------------//
		, insertScore:function(arg){			
			var thisClass = this;
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
			objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "registScoreCard");
        	
        	objJson.putParameter("reservSeq", arg["예약코드"]);
        	objJson.putParameter("roundDate", arg["라운드정보"]["일자"]);
			objJson.putParameter("golfclubId", arg["골프장코드"]);
			objJson.putParameter("courseInfoId1", arg["코스코드1"]);
			objJson.putParameter("courseInfoId2", arg["코스코드2"]);
			objJson.putParameter("courseInfoId3", arg["코스코드3"]);
			objJson.putParameter("holeCnt1", _util.roundEx(arg["홀1"]/2));
			objJson.putParameter("holeCnt2", _util.roundEx(arg["홀2"]/2));
			objJson.putParameter("holeCnt3", "");
			objJson.putParameter("fileSeq", arg["파일코드"]);
			objJson.putParameter("saveFileName", arg["파일명"]);
			objJson.putParameter("orgnFileName", arg["원본파일명"]);
			objJson.putParameter("contents", arg["내용"]);
			
			var outCard = arg["아웃코스"];
			var inCard = arg["인코스"];
			
			for(var i=0;i<outCard.length;++i){
				objJson.putParameter("par" + (i+1),  outCard[i]["파"]);
				objJson.putParameter("score" + (i+1),  outCard[i]["스코어"]);
			}
			
			for(var i=0;i<inCard.length;++i){
				objJson.putParameter("par" + (i+outCard.length+1),  inCard[i]["파"]);
				objJson.putParameter("score" + (i+outCard.length+1),  inCard[i]["스코어"]);
			}
			
        	cm.requestGetDev(objJson.getJsonString(), function(ret){
				
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"]=="00000"?true:false)
					, "메세지": (ret["msp"]["contents"]["serviceResult"]=="00000"?"스코어가 등록되었습니다.":"오류발생")
				}
				
				$(thisClass).trigger("evtFinishInsertScore", resData);
			}, function($err) {
				alert($err);
			});					
			
		}
//------------------------ 스코어등록------------------------//
	}
	
	//컨트롤파일
	function MyScoreRecord(){
		this.reserv_seq = null;
		
		this.objComm = null;
		this.objScoreRecord_List = null;
		this.objScoreRecord_Date = null;
		this.objScoreRecord_Course = null;
		this.objScoreRecord_Hole = null;
		this.objScoreRecord_File = null;
		this.objScoreRecord_Text = null;
		this.objScoreRecord_Card = null;
	};
	
	MyScoreRecord.prototype = {
	    onPageShow : function() {
	    	$("a").attr("href", "").attr("data-rel", "");
	    	$("section#my_score_record>section a").attr("href", "");
	    	this._init();	    	
	    }
	    , _init: function(){	
	    	this.objComm = new clsComm_MyScoreRecord();
	    	
	    	this.objScoreRecord_List = new clsScoreRecord_List();
			this.objScoreRecord_Date = new clsScoreRecord_Date();
			this.objScoreRecord_Course = new clsScoreRecord_Course();
			this.objScoreRecord_Hole = new clsScoreRecord_Hole();
			this.objScoreRecord_File = new clsScoreRecord_File();
			this.objScoreRecord_Text = new clsScoreRecord_Text();
			this.objScoreRecord_Card = new clsScoreRecord_Card();
	      
	      	this.getParam();  
	      	
	      	this._role();
	      
	      	this._bind();
	      	this._eventFinish();     	
	    }
	    , _start: function(){
	    	//스케줄정보 조회
	    	this.spinStart();
	      	this.objComm.getScoreScheduleList();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//스케줄조회 완료이벤트
		 	$(this.objComm).bind("evtFinishScheduleList", function(event){
		 		var thisData = thisClass.objComm.getScoreScheduleListData();
		 		thisClass.objScoreRecord_List.setList(thisData);		 		
		 		thisClass.spinEnd();
		 	});
		 	
		 	//스코어등록 완료 이벤트
		 	$(this.objComm).bind("evtFinishInsertScore", function(event, resData){
		 		alert(resData["메세지"]);
		 		if(resData["응답코드"]){
		 			//초기화
		 			_gf.MYPAGE_DATA = null;
		 			$.mobile.changePage("my_score.html","slide",true);
		 		}
		 		
		 		thisClass.spinEnd();
		 	});
	    }
		 , _bind: function(){
		 	var thisClass = this;
		 	
		 	this.objScoreRecord_List.$getLayer().on("change", "select", function(event){
		 		event.preventDefault();		 		
		 		var s = thisClass.objScoreRecord_List.$getLayer().find("select");
		 		var n = s.find("option").index(s.find("option:selected"));
		 		thisClass.objScoreRecord_List.setIdx(n);
		 	});
		 	//메뉴
		 	$("section#my_score_record nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();		 		
		 		$.mobile.changePage( "../inc/navi.html","slide",true);
		 	});
		 	
		 	//알림
		 	$("section#my_score_record nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 		    	
		 	//전체스코어
		 	$("section#my_score_record>footer ul li:eq(0) a").click(function(event){
		 		event.preventDefault();	
		 		$.mobile.changePage("my_score.html","slide",true);	
		 	});
		 	
		 	//스코어등록
		 	$("section#my_score_record>footer ul li:eq(1) a").click(function(event){
		 		event.preventDefault();	
		 		$.mobile.changePage("my_score_record.html","slide",true);	
		 	});
		 	
		 	//나의스코어통계
		 	$("section#my_score_record>footer ul li:eq(2) a").click(function(event){
		 		event.preventDefault();	
		 		$.mobile.changePage("my_score_state.html","slide",true);	
		 	});
		}
		, getParam: function(){			
			this.reserv_seq = _gf.MYPAGE_DATA["예약코드"];
				    	
		}
	   , _role: function(){
	   		this._start();
	  	} 
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}
	
	$(document).ready(function(){
		new MyScoreRecord().onPageShow();
	})